<?php
namespace Admin\Model;
use Think\Model;
header("Content-Type:text/html; charset=utf-8");
class LoginModel extends Model {
	protected $autoCheckFields = false;  //关闭字段信息的自动检测
	public function index(){	
		$list = array(
				'title' =>'基因科技' ,			
					);
		return $list;
	}

		//登录验证
	public function login(){
		$name=I('name');
		$password=I('password');
		if (empty($name)) {
			return '姓名不能为空';
		}
		if (empty($password)) {
			return '密码不能为空';
		}		
		$admin=M('admin');
		$user=$admin->find();
		$username=$user['name'];
		$upassword=$user['password'];
		
		if ($name!=$username || $upassword!=md5($password)) {
			return '2';
		}else{
			 session('username',$user['name']);
			 session('upassword',$user['password']);
			 session('time',time());	
			return '1';			
		}
		
	}
	
	
	
	 

	
	
	
	
}
?>